class HomeModel {
  List<HomeData> data;
  int errorCode;
  String errorMsg;

  HomeModel({this.data, this.errorCode, this.errorMsg});

  HomeModel.fromJson(Map<String, dynamic> json) {
    if (json['data']['rows'] != null) {
      data = new List<HomeData>();
      json['data']['rows'].forEach((v) {
        data.add(new HomeData.fromJson(v));
      });
    }

    errorCode = json['errorCode'];
    errorMsg = json['errorMsg'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.data != null) {
      data['data'] = this.data.map((v) => v.toJson()).toList();
    }
    data['errorCode'] = this.errorCode;
    data['errorMsg'] = this.errorMsg;
    return data;
  }
}

class HomeData {
  var productCourse; //科目：语文、数学、物理等
  var productName; //课程名称
  var startDate; //开始日期
  var endDate; //结束日期
  var rnNumber; //共多少节课，暂无
  var teacherHead; //教师头像mongodbid
  var teacherName; //教师名字
  var nowNumber; //报名人数
  var productNowPrice; //当前价格
  var productOldPrice; //现价
  HomeData(
      {this.productCourse,
        this.productName,
        this.startDate,
        this.endDate,
        this.rnNumber,
        this.teacherHead,
        this.teacherName,
        this.nowNumber,
        this.productNowPrice,
        this.productOldPrice});

  factory HomeData.fromJson(Map json) {
    return HomeData(
        productCourse: json['PRODUCT_COURSE'],
        productName: json['PRODUCT_NAME'],
        startDate: json['START_DATE'],
        endDate: json['END_DATE'],
        rnNumber: json['RN_NUMBER'],
        teacherHead: json['TEA_MONGODB_ID'],
        teacherName: json['TEACHERNAME'],
        nowNumber: json['NOW_NUMBER'],
        productOldPrice: json['PRODUCT_OLD_PRICE'],
        productNowPrice: json['PRODUCT_NOW_PRICE']);
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['PRODUCT_COURSE'] = this.productCourse;
    data['PRODUCT_NAME'] = this.productName;
    data['START_DATE'] = this.startDate;
    data['END_DATE'] = this.endDate;
    data['RN_NUMBER'] = this.rnNumber;
    data['TEA_MONGODB_ID'] = this.teacherHead;
    data['TEACHERNAME'] = this.teacherName;
    data['NOW_NUMBER'] = this.nowNumber;
    data['PRODUCT_OLD_PRICE'] = this.productOldPrice;
    data['PRODUCT_NOW_PRICE'] = this.productNowPrice;
    return data;
  }
}
